@extends('layout.app')

@section('content')

    <div class="box-body">

        <table id="rowed3"></table>
        <div id="prowed3"></div>

    </div>

<script>

$(document).ready(function() {

    var data = {
        // url :"/order/order",
        url:<?php echo $request->get('url') ? '"'.Request::getRequestUri().'"' : '"/order/order"'; ?>,

        postData: postData(),
        colNames: ['订单号' , '下单玩家id' , '昵称' ,'邀请者ID','隶属伙伴', '下单时间' , '彩票期号' , '商品名称' ,'折扣类型', '竞猜选项' , '数量' , '<i class="fa fa-jpy"></i> 单价' ,'总金额','开奖结果', '结果' , '订单状态'],
        colModel: [
            {
                name: 'orders.id',
                key: true
            }, {
                name: 'user_id'
            }, {
                name:'nickname',
                sortable: false
            },
            {
                name: 'bindid',
            },
            {
                name: 'zongdai',
            }, {
                name: 'orders.time',
                formatter:'date',
                formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'},
                searchoptions: {
                sopt: ['lt', 'le', 'gt', 'ge'],
                    dataInit : function (elem) {
                        $(elem).datepicker({
                            dateFormat: 'yy-mm-dd',
                            monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                            dayNamesMin: ['日','一','二','三','四','五','六'] });
                    }
                }
            }, {
                name: 'number'
            }, {
                name: 'goods.name',
                sortable: false
            },{
                name: 'orders.discount_type',
                sortable: false,
                hidden : true,
                stype: 'select',
                searchoptions:{
                    searchhidden:true,
                    sopt: ["eq" , "ne"],
                    value: "0:5折;1:2.5折;2:1折"
                }
            }, {
                name: 'type',
                stype: 'select',
                searchoptions: {
                    sopt: ["eq" , "ne"],
                    value: "1:小;2:大;3:单;4:双;5:大单;6:小双;7:小单;8:大双;0:特码",
                },
                formatter: function(cellvalue,options,row) {
                    discount = row['discount_type'];
                    cellvalue = cellvalue.toString();
//                     if(discount == 2) {
//                         rows = eval('(' + row['res'] + ')');
//                         data = '';
//                         for (i in rows)
//                         {
//                             data += '数'+i+'('+rows[i]+')<br>';
//                         }
//                         return data
//                     }
                    
                    switch (cellvalue) {
                        case "1":
                            return discount == 0 ? '单' : '大单';
                        case "2":
                            return discount == 0 ? '双' : '小双';
                        case "3":
                            return discount == 0 ? '大' : '小单';
                        case "4":
                            return discount == 0 ? '小' : '大双';
                        case "5":
                            return '大单';
                        case "6":
                            return '小双';
                        case "7":
                            return '小单';
                        case "8":
                            return '大双';
                        case "0":
                         rows = eval('(' + row['res'] + ')');
                         data = '';
                         for (i in rows)
                         {
                             data += '数'+i+'('+rows[i]+')<br>';
                         }
                         return data;
                    }
                    return "";
                }
            }, {
                name: 'num'
            }, {
                name: 'amounts'
            },
            {
                name: 'mount',
                sortable: false,
                search: false
            },
            {
                name: 'lottery_value',
                formatter: function(cellvalue,options,row) {
                    if(!cellvalue) {
                        return '-';
                    }
//                     var arr = cellvalue.split(",");
//                     num = arr[0]*1+arr[1]*1+arr[2]*1;
                    if (cellvalue % 2 == 1) {
                        ds = '单';
                    } else {
                        ds = '双';
                    }
//                     if (num > 13) {
//                         dx = '大';
//                     } else {
//                         dx = '小';
//                     }
                    return cellvalue + '('+ds+')';
                }
            },{
                name: 'win',
                sortable: false,
                stype: 'select',
                searchoptions: {
                    sopt: ["eq", "ne"],
                    value: "0:开奖中;1:中奖;2:未中奖"
                },
                formatter: function(cellvalue) {
                    cellvalue = cellvalue.toString();
                    switch (cellvalue) {
                        case "0":
                            return "-";
                        case "1":
                            return '中奖';
                        case "2":
                            return '未中奖';
                    }
                    return "";
                }
            }, {
                name: 'status',
                sortable: false,
                stype: 'select',
                searchoptions: {
                    sopt: ["eq", "ne"],
                    value: "0:未使用;3:转卖中;4:已转卖;5:待确认收货;6:已确认收货"
                },
                formatter: function(cellvalue) {
                    cellvalue = cellvalue.toString();
                    switch (cellvalue) {
                        case "0":
                            return "未使用";
                        case "3":
                            return '转卖中';
                        case "4":
                            return '已转卖';
                        case "5":
                            return '待确认收货';
                        case "6":
                            return '已确认收货';
                    }
                    return "";
                }
            }],
        caption: '<i class="fa fa-list"></i> {{$label2}}',
        sortname: 'orders.id',
        sortorder: "desc",
        gridComplete: function() {
            $(this).footerData("set", {
                "mount": $(this).getCol("mount", false, "sum")});
        }
    };

    jqGrid(data);
});
function postData() {
    return {
        user_id: '<?php echo $request->get("user_id")?>',
        ids: "<?php echo $request->get("ids")?>"
    }
}
</script>
@endsection